package com.panshi.qiniuyun;

import cn.hutool.core.date.DateUtil;

import java.util.UUID;

/**
 * 七牛云工具类
 */
public class QiniuUtils {

    public static String getRandomImgName(String fileName){

        int index = fileName.lastIndexOf(".");

        if((fileName == null || fileName.isEmpty()) || index == -1){
            throw new IllegalArgumentException();
        }
        //获取文件后缀
        String suffix = fileName.substring(index);
        //生成UUID
        String uuid = UUID.randomUUID().toString().replaceAll("-","");
        //生成上传至云服务的路径
        String path = "code/duck/"+ DateUtil.today() + "-" + uuid + suffix;

        return path;

    }


}
